<template>
    <div>
        <c-title :text="title"></c-title>
        <div style="padding-top: 0.625rem;margin:0 .75rem .625rem;">
            <GoodList :goodsList="list" :aggregate_module_code="platform_index"></GoodList>
        </div>
    </div>
</template>

<script>
import GoodList from "./component/goods.vue";
import { scrollMixin } from "../../../utils/mixin";
export default {
    mixins: [scrollMixin],
    data() {
        return {
            title: "",
            platform_index: '',//平台类型 1抖音2淘宝3京东
            list: [],
            current_page: 1,
            last_page: 1,
            isLoadMore: true,

        };
    },
    activated() {
        this.platform_index = this.$route.query.aggregate_module_code;
        this.title = this.$route.query.title;
        this.fun.setWXTitle(this.$route.query.title);
        this.getData();
    },

    methods: {
        getData(page = 1) {
            let json = {
                page,
                album_id: this.$route.query.album_id,
                aggregate_module_code: this.$route.query.aggregate_module_code
            }
            $http.get('plugin.tiktok-cps.api.goods.album-good-list', json, ',').then(({ result, msg, data }) => {
                if (result) {
                    this.isReady = true;
                    if (this.platform_index == 2) {
                        this.list = data;
                    } else {
                        this.list = data.current_page == 1 ? data.data : this.list.concat(data.data);
                        this.current_page = Number(data.current_page);
                        this.last_page = data.last_page;
                    }
                    this.isLoadMore = true;
                    console.log(data);
                } else {
                    this.$toast(msg);
                }
            })
        },
        getMoreData() {
            if (this.current_page >= this.last_page) {
                return;
            }
            this.isLoadMore = false;
            let page = this.current_page + 1;
            this.getData({ page, order_type: this.order_type, search_type: this.search_type, cate_id: this.cate_id });
        }
    },
    components: { GoodList }
};
</script>

<style scoped lang='scss'>
/** **/
</style>